class RswlStats(object):


    def __init__(self):
        '''
        Constructor
        '''
        
    def Apply(self, network):
        swModelNameList = []
        
        for fieldName in network.__dict__.keys():
            if fieldName.startswith("alternativeSwDict_"):
                swModelNameList.append(fieldName[len("alternativeSwDict_"):])
                
        for actualModelName in swModelNameList:
            actualSwDict = network.__dict__["alternativeSwDict_" + actualModelName]
            bestAlternative = network.__dict__["bestAlternative_" + actualModelName]

            swForBestAlternative = actualSwDict[bestAlternative]
            swForWorstAlternative = min(actualSwDict.values())
            
            wswl = (swForBestAlternative - swForWorstAlternative) / float(swForBestAlternative) 

            network.__dict__["wswl_" + actualModelName] = wswl
            
            for assumedModelName in swModelNameList:
                
                if (actualModelName != assumedModelName):

                    assumedBestAlternative = network.__dict__["bestAlternative_" + assumedModelName]
                    swForAssumedBestAlternative = actualSwDict[assumedBestAlternative]

                    rswl = (swForBestAlternative - swForAssumedBestAlternative) / float(swForBestAlternative)
                    
                    nswl = 0
                    if wswl != 0:
                        nswl = rswl / wswl
                        
                    network.__dict__["rswl_actual-" + actualModelName + "_assumed-" + assumedModelName] = rswl
                    network.__dict__["nswl_actual-" + actualModelName + "_assumed-" + assumedModelName] = nswl